OpenDialog na adresare
Otázka od: Sula Milos
7. 10. 2002 10:26
Existuje pro delphi nejaky OpenDialog ale pouze pro vyber adresare (ne
souboru)?
Milos
Odpovedá: Ludo Fulop
7. 10. 2002 12:00
je na to API funkcia "SHBrowseForFolder"
Ludo Fulop
----- Original Message -----
From: "Sula Milos" <milos.sula@oku-su.cz>
To: <delphi-l@clexpert.cz>
Sent: Monday, October 07, 2002 11:22 AM
Subject: OpenDialog na adresare
Existuje pro delphi nejaky OpenDialog ale pouze pro vyber adresare (ne
souboru)?
Milos
Odpovedá: Petr Brant
7. 10. 2002 11:59
Muzes pouzit funkci SelectDirectory anebo unit, ktery jsem na to napsal (viz
nize). U toho unitu lze urcit jeste adresar, na ktery se ma adresarova
struktura rozbalit, myslim, ze funkce SelectDirectory tohle neumi.
RNDr. Petr Brant [brant@dcomm.cz]
D&COMM s.r.o.
Korunovační 6
Praha 7
tel. +420724007234
unit BrowseDir;
interface
uses
Windows,
ShlObj, SysUtils, FileCtrl;
type TBrowseDirectory = class(TObject)
private
{ Private declarations }
public
{ Public declarations }
function BrowseForDirectory(OwnerWnd:THandle; InitialDirectory: string; var
SelectedDirectory:string):boolean;
end;
implementation
uses ActiveX;
var m_InitialDirectory:string;
function BrowseCallbackProc(Wnd: HWnd; Msg: UINT; lPar: LPARAM; lData:
LPARAM): integer; stdcall; begin Result := 0; if (Msg = BFFM_INITIALIZED)
and DirectoryExists(m_InitialDirectory) then
SendMessage(Wnd, BFFM_SETSELECTION, 1, LPARAM(m_InitialDirectory) );
end;
function TBrowseDirectory.BrowseForDirectory(OwnerWnd:THandle;
InitialDirectory: string; var SelectedDirectory:string):boolean;
var BrowseInfo: TBrowseInfo;
idRoot: PItemIDList;
Dir: PChar;
ShellMalloc: IMalloc;
begin
FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);
if (ShGetMalloc(ShellMalloc) = S_OK) and (ShellMalloc <> nil) then begin
Dir:= ShellMalloc.Alloc(MAX_PATH);
try
m_InitialDirectory:=InitialDirectory;
BrowseInfo.hwndOwner:=OwnerWnd;
BrowseInfo.pidlRoot:=idRoot;
BrowseInfo.lpszTitle:='';
BrowseInfo.ulFlags:= BIF_RETURNONLYFSDIRS;
BrowseInfo.lpfn:=BrowseCallbackProc;
BrowseInfo.pszDisplayName:=Dir;
idRoot:=ShBrowseForFolder(BrowseInfo);
Result:=false;
if idRoot<>nil then
begin
SHGetPathFromIDList(idRoot, Dir);
SelectedDirectory:=string(Dir);
ShellMalloc.Free(idRoot);
Result:=(Length(SelectedDirectory)<>0);
end;
finally
ShellMalloc.Free(Dir);
end;
end;
end;
end.
Subject: OpenDialog na adresare
Existuje pro delphi nejaky OpenDialog ale pouze pro vyber adresare
(ne
souboru)?
Milos
Odpovedá: Bohdan Dudla
7. 10. 2002 12:35
Ahoj.
V modulu FileCtrl existuje funkce SelectDirectory a nekolik dalsich
uzitecnych funkci.
With best regards,
Bohdan Dudla
Pike Electronic spol. s r.o.
Modrinova 2
300 00 Plzen
Czech Republic
tel: +420 19 72 40 738
fax: +420 19 74 31 738
gsm: +420 732 441 716
e-mail: bdudla@pikeelectronic.com